﻿using Syncfusion.WinForms.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WinForm.NET4.Sample.Extensions;

namespace WinForm.NET4.Sample
{
    public partial class Login : SfForm
    {
        public Login()
        {
            InitializeComponent();

            Bitmap imge = new Bitmap(Image.FromFile("Images\\login.png"));
            this.Icon = Icon.FromHandle(imge.GetHicon());
            this.IconSize = new Size(32, 32);





          
            this.Style.TitleBar.AllowRichText = true;
            this.Text = "{\\rtf1\\ansi\\deff0{\\colortbl;\\red0\\green0\\blue0;\\red244\\green120\\blue8;}" + "{\\fonttbl{\\f0 Segoe UI;\r\n}}\\qc\\f0\\fs25 {\\cf1 登录 - \\cf2 \\b Win Form Sample}}";
             


            this.Style.TitleBar.Height = 40;
            this.Style.TitleBar.BackColor = Color.White;
            //this.Style.TitleBar.IconBackColor = Color.FromArgb(15, 161, 212);
            this.BackColor = Color.White;
            this.Style.TitleBar.ForeColor = ColorTranslator.FromHtml("#343434");
            this.Style.TitleBar.CloseButtonForeColor = Color.DarkGray;
            this.Style.TitleBar.MaximizeButtonForeColor = Color.DarkGray;
            this.Style.TitleBar.MinimizeButtonForeColor = Color.DarkGray;
            this.Style.TitleBar.HelpButtonForeColor = Color.DarkGray;
            this.Style.TitleBar.IconHorizontalAlignment = HorizontalAlignment.Left;
            this.Style.TitleBar.Font = this.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Style.TitleBar.TextHorizontalAlignment = HorizontalAlignment.Center;
            this.Style.TitleBar.TextVerticalAlignment = System.Windows.Forms.VisualStyles.VerticalAlignment.Center;
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if(this.txtUserName.Text.Trim()=="admin" && this.txtPassword.Text == "admin")
            {
                this.DialogResult = DialogResult.Yes;

                IdentityContext.Current.UserName = this.txtUserName.Text.Trim();
                IdentityContext.Current.UserType = "管理员";

            }
            else
            {
                MessageBox.Show(this,"用户名或密码不正确.","警告",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }
    }
}
